#include "choosedlg.h"
#include <QVBoxLayout>

ChooseDlg::ChooseDlg()
{
    QPalette palette;
    QPixmap pix(":/img/jiemian.jpg");
    palette.setBrush(backgroundRole(), QBrush(pix.scaled(this->size())));
    setPalette(palette);
    resize(QSize(600,400));

    QVBoxLayout* lay = new QVBoxLayout(this);
    //lay->setGeometry(QRect(0,100,200,200));
    lay->setContentsMargins(200,300,200,20);
    lay->addWidget(buttons[0] = new QPushButton("AI(Easy)"));
    lay->addWidget(buttons[1] = new QPushButton("AI(Hard)"));
    lay->addWidget(buttons[2] = new QPushButton("Network(Server)"));
    lay->addWidget(buttons[3] = new QPushButton("Network(Client)"));

    for (int i = 0; i < 4; i++)
        connect(buttons[i], SIGNAL(clicked()), this, SLOT(slotClicked()));

}

void ChooseDlg::slotClicked()
{
    for(int i=0; i < 7; i++)
        if(buttons[i] == sender())
        {
            this->selected = i;
            break;
        }
    accept();
}
